sql counting duplicates
am 14.04.2006 11:47:36 von dejanHy
I have this code:
------------------------------------------------------------ ------------
$result = mysql_query("select * from smjestaj left join grad on
grad.grad=smjestaj.grad_pbroj order by grad_pbroj ASC", $db) or die ("Could
not read data because ".mysql_error());
// print the data in a table
if (mysql_num_rows($result)) {
print "
Grad |
"lista_sa_linkovima_po_gradovima.php?grad=$qry[grad_pbroj]\" >$qry[Naziv] | ";
}
mysql_close($db);
------------------------------------------------------------ ------------
Table smjestaj has coloumns:
id | Name | grad_pbroj | ...
Table grad has coloumns:
grad_pbroj | Naziv|
Now i wanna display all the grad_pbroj coloumns from 'smjestaj', buth not
displaying duplicates, just to count them, and put the count behind the
'grad_pbroj' coloumn.
Result:
Naziv_first (3)
Naziv_second (1)
Naziv_third (8)
I nead full solution, because i have tried everythig and either sql of php
displaying is fucking me.
I have tried all of that group by, count sql syntax, and i allways get
error.
Anyone cann help me plz.
Dejan
ps. sorry to all the people i have asked this before, buth not giving full
description (Arjen, Jerry Stuckle).